﻿<UserControl
    x:Name="uc"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:c2iGMailNotifier="clr-namespace:c2iGMailNotifier" 
    xmlns:View="clr-namespace:c2iGMailNotifier.View"
    xmlns:Converter="clr-namespace:c2iGMailNotifier.Converter" 
    x:Class="c2iGMailNotifier.View.EmailsListView"
    
    DataContext="{Binding Source={x:Static c2iGMailNotifier:Locator.EmailsListViewModelStatic}}"
	mc:Ignorable="d" d:DesignWidth="373" d:DesignHeight="424" >
    <UserControl.Resources>
        <Converter:DateTimeConverter x:Key="dateTimeConverter"/>
    </UserControl.Resources>
    <Border Background="Transparent" BorderThickness="1" BorderBrush="Black">
        <Grid>
            <Viewbox >
                <TextBlock Text="{Binding AtomEntries.Count}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="#5DFFFFFF"/>
            </Viewbox>

            <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
                <ItemsControl ItemsSource="{Binding AtomEntries}" Margin="4"  >
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5" Margin="0,2" Padding="5" Background="{DynamicResource ItemBackgroundBrush}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="5"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock 
											Text="{Binding AuthorName}" 
											Margin="2"/>
                                    <TextBlock 
											Text="{Binding Modified, Converter={StaticResource dateTimeConverter}}" 
											Margin="2" 
											Grid.Column="1" 
											HorizontalAlignment="Right" />
                                    <Button 
                                        HorizontalContentAlignment="Left"
                                        Content="{Binding Title}" 
                                        Style="{DynamicResource HyperlinkStyle}" 
                                        Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type View:EmailsListView}}, Path=DataContext.NavigateCommand}"
                                        CommandParameter="{Binding Link}" 
                                        Margin="2"
                                        Grid.Row="1" 
                                        Grid.ColumnSpan="2"/>

                                </Grid>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>

                </ItemsControl>
            </ScrollViewer>

        </Grid>
    </Border>
</UserControl>
